/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import com.sun.lwuit.Command;
import com.sun.lwuit.Label;
import com.sun.lwuit.TextArea;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.layouts.BoxLayout;
import core.ScreenEngine;
import view.commands.BackCommand;
import view.commands.EmptyCommand;

/**
 *
 * @author Kvest
 */
public class ConfirmConnectToExtraIPMessage extends BasicForm {  
    private static final int YES_COMMAND_ID = 1;
    private OnConfirmListener confirmListener;
    
    public ConfirmConnectToExtraIPMessage(OnConfirmListener confirmListener)
    {
        super();
        
        this.confirmListener = confirmListener;
        
        init();
    }
    
    private void init()
    {
        setTitle("");
        
        setLayout(new BoxLayout(BoxLayout.Y_AXIS));
        setCyclicFocus(false);
        
        TextArea text = new TextArea((new Label("try_extra_server")).getText(), 1, 30);
        text.setEditable(false);
        text.setGrowByContent(true); 
        addComponent(text);

        addCommand(new EmptyCommand());
        
        BackCommand noCommand = new BackCommand();
        noCommand.setCommandName("no");
        addCommand(noCommand);
        
        Command yesCommand = new Command("yes", YES_COMMAND_ID) 
        {
            public void actionPerformed(ActionEvent evt)
            { 
                ScreenEngine.getEngine().pop(true);
                
                if (confirmListener != null) {
                    confirmListener.onConfirm();
                }
                
                evt.consume();
            }
        };
        addCommand(yesCommand);
    }
    
    public interface OnConfirmListener {
        public void onConfirm();
    }
}
